﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HotelSoft.HotelManagement_BUS;
using HotelSoft.HotelManagement_DTO;

namespace HotelSoft.HotelManagement_GUI
{
    public partial class frmTRAPHONG_Commit : Form
    {
        // Define the CS_DROPSHADOW constant
        private const int CS_DROPSHADOW = 0x00020000;

        // Override the CreateParams property
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ClassStyle |= CS_DROPSHADOW;
                return cp;
            }
        }

        Double temp = 1;
        private static string soPDK="";
        private static DateTime ngayTT;
        private static DateTime ngayT;

        public DateTime NGAYTHUE
        {
            get { return ngayT; }
            set { ngayT = value; }
        }

        public DateTime NGAYTHANHTOAN
        {
            get { return ngayTT; }
            set { ngayTT = value; }
        }
        public string SOPHIEUDK
        {
            get { return soPDK; }
            set { soPDK = value; }
        }
        public frmTRAPHONG_Commit()
        {
            InitializeComponent();
        }

        private void frmTRAPHONG_Commit_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            if (soPDK != "")
            {
                DateTime nt, ntt;
                ntt = ngayTT;
                nt = ngayT;
                lblNgaythanhtoan.Text = ntt.ToShortDateString();
                lblNgaythue.Text = nt.ToShortDateString();
                txtSongaythue.Text = countSNT(nt, ntt).ToString();
                btnAccept.Focus();
            }
        }

        public int countSNT(DateTime NT, DateTime NTT)
        {
            return  (int)((TimeSpan)(NTT - NT)).TotalDays + 1;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Opacity = this.Opacity + 0.1;
            if (this.Opacity == temp)
            {
                timer1.Enabled = false;
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnAccept_Click(object sender, EventArgs e)
        {
            PhieuDangKyDTO dtoPDK = new PhieuDangKyDTO();
            dtoPDK.SoPDK = soPDK;
            dtoPDK.SoNgayThue = int.Parse(txtSongaythue.Text);
            PhieuDangKyBUS busPDK = new PhieuDangKyBUS();
            busPDK.UpdateNgayThue(dtoPDK);
            this.Close();
        }
    }
}
